import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

// 导入模块
import app from './modules/app'
import auth from './modules/auth'
import product from './modules/product'
import order from './modules/order'
import user from './modules/user'

Vue.use(Vuex)

// 创建Store实例
export default new Vuex.Store({
  modules: {
    app,
    auth,
    product,
    order,
    user
  },
  // 持久化存储配置
  plugins: [
    createPersistedState({
      key: 'kj-erp-state',
      paths: ['auth.token', 'auth.user', 'app.settings', 'app.sidebarCollapsed']
    })
  ],
  // 严格模式，防止直接修改状态
  strict: process.env.NODE_ENV !== 'production'
}) 